<!DOCTYPE html>
<html>
  <head>
  <script type="text/javascript" src="/resources/js/chrome_ex_oauthsimple.js"></script>
	<script type="text/javascript" src="/resources/js/chrome_ex_oauth.js"></script>
	<script type="text/javascript" src="/resources/js/jquery-1.6.2.min.js"></script>
	<script type="text/javascript" src="/resources/js/jquery.timers.js"></script>
	<script type="text/javascript" src="/app/globals.js"></script>
	<script type="text/javascript" src="/app/model.js"></script>
	<script type="text/javascript" src="/app/options.js"></script>
	<script type="text/javascript" src="/app/spreadsheet.js"></script>
	<script type="text/javascript" src="/app/voc.js"></script>	
	<script type="text/javascript" src="/app/utils.js"></script>
	<script type="text/javascript" src="/app/main.js"></script>
	<script type="text/javascript" src="/app/notification.js"></script>	
	

    <script type="text/javascript">
    
    var SHEET_VOC_NAME = 'YoVoc';
    
    var SHEETLIST_SCOPE = 'https://spreadsheets.google.com/feeds';
    var SHEETLIST_FEED = SHEETLIST_SCOPE + '/spreadsheets/private/full/';
    var DOC_FEED_SCOPE = 'https://docs.google.com/feeds';
	var DOC_FEED_URL = 'https://docs.google.com/feeds/default/private/full/';
      
      var localVoc = [];
      
      var oauth = ChromeExOAuth.initBackgroundPage({
        'request_url' : 'https://www.google.com/accounts/OAuthGetRequestToken',
        'authorize_url' : 'https://www.google.com/accounts/OAuthAuthorizeToken',
        'access_url' : 'https://www.google.com/accounts/OAuthGetAccessToken',
        'consumer_key' : 'anonymous',
        'consumer_secret' : 'anonymous',
        'scope' : DOC_FEED_SCOPE+" "+SHEETLIST_SCOPE,
        'app_name' : 'YoVoc - Youniversal Vocabulary'
      });
      
      function logout() {
        oauth.clearTokens();
      };

      	function getSelection(info, tab) {
	
		if(!info.selectionText || info.selectionText == 0) {
		 return;	
		}
	
 		var maxChar = 120;
		var serchable = (info.selectionText.length <= maxChar) ? info.selectionText : info.selectionText.substr(0,maxChar);
		
		Voc.addTerm(new Term(serchable, ''));
      	}
      
     	  chrome.contextMenus.create({
		"title": "Add to YoVoc",
		"contexts":["selection"],
		"onclick":getSelection
      	  });

    </script>
  </head>
  <body>
  </body>
</html>
